package com.example.mform.controller;

import com.example.mform.entity.Question;
import com.example.mform.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author shishuqian
 * date 2020/12/17
 * time 0:53
 **/
@RestController
@RequestMapping("/question")
public class QuestionController {

    @Autowired
    private QuestionService questionService;

    @GetMapping("/findAll")
    public List<Question> findAll(){
        return questionService.findAll();
    }

    @GetMapping("/findById/{id}")
    public Question findById(@PathVariable("id") Long id){
        return questionService.findById(id);
    }

    @PostMapping("/save")
    public void save(@RequestBody Question question){
        questionService.save(question);
    }

    @PutMapping("/update")
    public void update(@RequestBody Question question){
        questionService.save(question);
    }

    @DeleteMapping("/deleteById/{id}")
    public void  deleteById(@PathVariable("id") Long id){
        questionService.deleteById(id);
    }
}
